package com.example.wei;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

public class WeathAdapter extends RecyclerView.Adapter<WeathAdapter.MyViewHolder> {

    private ArrayList<WeathBenan.DataDTO> arrayList;

    public WeathAdapter(ArrayList<WeathBenan.DataDTO> arrayList) {

        this.arrayList = arrayList;

    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {

        WeathBenan.DataDTO bean = arrayList.get(position);
        holder.mainTextView.setText(bean.getDate());
        holder.contentTextView.setText(bean.getDate() + "|" + bean.getWeek());
        holder.contentTextView.append(bean.getTem1()+" ~ " + bean.getTem2() + " | " + bean.getWin());

    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list_weath, parent, false);
        return new MyViewHolder(view);
    }

    @Override
    public int getItemCount() {

        return arrayList.size();

    }

    static class MyViewHolder extends RecyclerView.ViewHolder {

        private final AppCompatTextView mainTextView;
        private final AppCompatTextView contentTextView;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            mainTextView = itemView.findViewById(R.id.mainTextView);
            contentTextView = itemView.findViewById(R.id.contentTextView);
        }

    }

}